package com.shass.xposed.youku;

import android.app.Application;
import android.content.Context;
import de.robv.android.xposed.IXposedHookLoadPackage;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;
import de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam;

/**
 * hook 入口 <br />
 * 拦截广告方法，返回空
 * @author shass
 *
 */
public class App implements IXposedHookLoadPackage{

	@Override
	public void handleLoadPackage(LoadPackageParam loadPackageParam) throws Throwable {
		XposedHelpers.findAndHookMethod(Application.class, "attach", Context.class,new XC_MethodHook(){
			protected void afterHookedMethod(MethodHookParam param) throws Throwable {
				Class<?> clazz = null ;
				Context context = (Context)param.args[0] ;
				try {
					clazz = context.getClassLoader().loadClass("com.youku.upsplayer.module.VideoInfo") ;
				} catch (Exception e) {
				}
				if (clazz != null) {
					XposedHelpers.findAndHookMethod(clazz, "getAd", new XC_MethodHook() {
		                @Override
						protected void beforeHookedMethod(MethodHookParam param) throws Throwable {
		                	param.setResult(null) ;
		                }
		            });
				}
            }
		}) ;
	}

}
